package org.springcloud.wisdom.springcloud_03_freshman.admin.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springcloud.wisdom.springcloud_03_freshman.index.login.entity.Freshman;
import org.springcloud.wisdom.springcloud_03_freshman.student.entity.Paid;

import java.util.List;
@Mapper
public interface AdminPaidDao {
    /**
     * 以分页的形式查看 新生信息
     * @param start 页码数
     * @param size 每页记录数
     * @param sdept 院系
     * @param status 学号
     * @return
     */
    @Select("<script>" +
            "SELECT * FROM paid" +
            "  <where>" +
            "    <if test=\"sdept != null\">" +
            "     sdept = #{sdept} " +
            "    </if>" +
            "    <if test=\"status != null\">" +
            "   and  status = #{status} " +
            "    </if>" +
            "</where>"+
            " ORDER BY" +
            "  CASE " +
            "    WHEN status = '已缴费' THEN 1" +
            "    WHEN status = '未缴费' THEN 2" +
            "    ELSE 3" +
            "  END," +
            "  status ASC "+
            "limit #{start},#{size}"+
            "</script>")
    public List<Paid> getPaidByCons(int start, int size, String status,Integer sdept);

    @Select("<script>" +
            "SELECT count(*) FROM paid" +
            "  <where>" +
            "    <if test=\"status != null\">" +
            "      status = #{status}" +
            "    </if>" +
            "    <if test=\"sdept != null\">" +
            "     and sdept = #{sdept} " +
            "    </if>" +
            "</where>"+
            "</script>")
    public int countPaid(String status,Integer sdept);
}
